package com.twt.sys.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.twt.model.system.entity.SysDict;
import com.twt.sys.base.BaseController;
import com.twt.common.pojo.Result;
import com.twt.common.utils.Assert;
import com.twt.model.system.entity.SysDictItem;
import com.twt.sys.base.BaseService;
import com.twt.sys.service.SysDictItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/sys/dict/item")
public class SysDictItemController extends BaseController<SysDictItem> {
    @Autowired
    private SysDictItemService sysDictItemService;


    @GetMapping("/query/page/{currentPage}/{pageSize}")
    public Result queryByDictId(@PathVariable("currentPage") long currentPage, @PathVariable("pageSize") long pageSize, SysDictItem queryVo) {
        Page<SysDictItem> page = new Page<>();
        page.setCurrent(currentPage);
        page.setSize(pageSize);
        Page<SysDictItem> sysDictItemPage = this.sysDictItemService.queryPageByQueryVo(page, queryVo);
        return Result.ok(sysDictItemPage);
    }

    @Deprecated
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") String id) {
        Assert.isBlank(id, "id 不能为空！");
        sysDictItemService.removeById(id);
        return Result.ok();
    }


    @Override
    protected BaseService getBaseService() {
        return sysDictItemService;
    }
}
